/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
#include <vector>
#include<iostream>
#include <string>
using namespace std;
struct TreeNode
{
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};
class Solution
{
public:
    vector<string> binaryTreePaths(TreeNode *root)
    {
        vector<string> ans;
        solve(root, ans, "");
        return ans;
    }
    void solve(TreeNode *node, vector<string> &paths, string path)
    {
        if (node != nullptr)
        {
            path += to_string(node->val);
            if (node->left == nullptr && node->right == nullptr)
            {
                paths.push_back(path);
            }
            else
            {
                path += "->";
                solve(node->left, paths, path);
                solve(node->right, paths, path);
            }
        }
    }
};
int main(int argc, char const *argv[])
{

    return 0;
}
